<!DOCTYPE html>
<html>

<head>
    <link rel="shortcut icon" href="assets/img/logo.png">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>UR Blog</title>
    <!-- Fonts -->
    <link href="https://fonts.googleapis.com/css?family=Nunito:400,600,700,800|Roboto:400,500,700" rel="stylesheet">
    <!-- Theme CSS -->
    <link type="text/css" href="assets/css/theme1.css" rel="stylesheet">
    <!-- Demo CSS - No need to use these in your project -->
    <link type="text/css" href="assets/css/demo.css" rel="stylesheet">
</head>

<body>
    <nav class="navbar navbar-expand-lg navbar-transparent navbar-dark bg-dark py-4">
        <div class="container">
            <a class="navbar-brand" href="blog_list.html"><strong>UR</strong> Blog</a>
            <button class="navbar-toggler" type="button" data-action="offcanvas-open" data-target="#navbar_main"
                aria-controls="navbar_main" aria-expanded="false" aria-label="Toggle navigation">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="navbar-collapse offcanvas-collapse" id="navbar_main">
                <ul class="navbar-nav ml-auto align-items-lg-center">
                    <h6 class="dropdown-header font-weight-600 d-lg-none px-0">Menu</h6>
                    <li class="nav-item ">
                    </li>
                    <li class="nav-item dropdown">
                    </li>
                    <li class="nav-item">
                    </li>
                    </li>
                    <div class="dropdown-divider d-lg-none my-4"></div>
                    <h6 class="dropdown-header font-weight-600 d-lg-none px-0">Social Media</h6>
                    <li class="nav-item">
                        <a class="nav-link nav-link-icon" href="https://gitee.com/liu-Nox" target="_blank"><i
                                class="fab fa-github"></i><span class="ml-2 d-lg-none">Github</span></a>
                    </li>
                </ul>
            </div>
        </div>
    </nav>
    <main class="main">
        <section class="py-xl bg-cover bg-size--cover"
            style="background-image: url('assets/images/backgrounds/img-1.jpg')">
            <span class="mask bg-primary alpha-6"></span>
            <div class="container d-flex align-items-center no-padding">
                <div class="col">
                    <div class="row justify-content-center">
                        <div class="col-lg-4">
                            <div class="card bg-primary text-white">
                                <div class="card-body">
                                    <button type="button" class="btn btn-primary btn-nobg btn-zoom--hover mb-5">
                                        <span class="btn-inner--icon" onclick="location.href='login.html'"><i
                                                class="fas fa-arrow-left"></i>登录</span>
                                    </button>
                                    <span class="clearfix"></span>
                                    <img src="assets/images/brand/icon.png" style="width: 50px;">
                                    <h4 class="heading h3 text-white pt-3 pb-5">忘记密码？<br>
                                        请输入你的账号.</h4>
                                    <div class="form-group">
                                        <input type="username" class="form-control" id="username" name="username"
                                            placeholder="账号">
                                    </div>
                                    <button type="submit" class="btn btn-block btn-lg bg-white mt-4"
                                        onclick="forgetPs()">Submit</button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>
    </main>
    <footer class="pt-5 pb-3 footer  footer-dark bg-tertiary">
        <div class="container">
            <div class="row">
                <div class="col-12 col-md-4">
                    <div class="pr-lg-5">
                        <h1 class="heading h6 text-uppercase font-weight-700 mb-3"><strong>UR</strong> Blog</h1>
                        <p>This blog is the first SSM project I did, which will be developed in 2023, and there is still
                            a lot of room for improvement.</p>
                    </div>
                </div>
            </div>
            <hr>
            <div class="d-flex align-items-center">
                <ul class="nav ml-lg-auto">
                    <li class="nav-item">
                        <a class="nav-link" href="https://gitee.com/liu-Nox" target="_blank"><i
                                class="fab fa-github"></i></a>
                    </li>
                </ul>
            </div>
        </div>
    </footer>
    <!-- Core -->
    <script src="js/jquery_min.js"></script>
    <script src="assets/vendor/popper/popper.min.js"></script>
    <script src="assets/js/bootstrap/bootstrap.min.js"></script>
    <!-- FontAwesome 5 -->
    <script src="assets/vendor/fontawesome/js/fontawesome-all.min.js" defer></script>
    <!-- Page plugins -->
    <script src="assets/vendor/bootstrap-select/js/bootstrap-select.min.js"></script>
    <script src="assets/vendor/bootstrap-tagsinput/bootstrap-tagsinput.min.js"></script>
    <script src="assets/vendor/input-mask/input-mask.min.js"></script>
    <script src="assets/vendor/nouislider/js/nouislider.min.js"></script>
    <script src="assets/vendor/textarea-autosize/textarea-autosize.min.js"></script>
    <!-- Theme JS -->
    <script src="assets/js/theme1.js"></script>
</body>

<script>
    //忘记密码发送邮件
    function forgetPs() {
        //1.非空校验
        var username = jQuery("#username");
        if (username.val() == "") {
            alert("请输入用户名！");
            return false;
        }
        //2.发送ajax给后端
        jQuery.ajax({
            url: "/user/checke",
            type: "get",
            data: {
                username: username.val(),
            },
            success: function (result) {
                if(result.data==null) {
                    alert("不存在该账号");
                    return;
                }
                if (result.data.email == null) {
                    alert("抱歉！由于您之前未绑定邮箱，无法找回密码");
                    return;
                }
                var email = prompt("请输入您之前绑定的邮箱");
                if (result.data.email == email) {
                    jQuery.ajax({
                        url: "/user/sendmail",
                        type: 'post',
                        data: {
                            username: username.val(),
                        },
                        success: function() {
                            alert("请在您的邮箱中查看邮件以更改密码");
                        },
                        error: function(body) {
                            alert("当前服务器繁忙");
                            console.log(body.msg)
                        }
                    })
                } else {
                    alert("抱歉，您输入的邮箱与当前账号绑定的邮箱不符");
                    return;
                }
            }
        })
    }
</script>

</html>